package com.eduagent.xwqeduagent.api.speechsynthesis.api.model;

import com.eduagent.xwqeduagent.api.speechsynthesis.api.constant.ErrorCode;

/**
 * 错误响应模型
 */
public class ErrorResponse {
    private int code;
    private String message;
    private String suggestion;
    private String sid;

    /**
     * 创建错误响应对象
     * @param code 错误码
     * @param sid 会话ID
     * @return 错误响应对象
     */
    public static ErrorResponse create(int code, String sid) {
        ErrorResponse response = new ErrorResponse();
        response.code = code;
        response.message = ErrorCode.getDescription(code);
        response.suggestion = ErrorCode.getSuggestion(code);
        response.sid = sid;
        return response;
    }

    /**
     * 创建错误响应对象，包含详细错误信息
     * @param code 错误码
     * @param sid 会话ID
     * @param detail 详细错误信息
     * @return 错误响应对象
     */
    public static ErrorResponse create(int code, String sid, String detail) {
        ErrorResponse response = new ErrorResponse();
        response.code = code;
        response.message = ErrorCode.getDescription(code) + "; " + detail;
        response.suggestion = ErrorCode.getSuggestion(code);
        response.sid = sid;
        return response;
    }

    /**
     * 创建引擎错误响应对象
     * @param code 引擎错误码
     * @param sid 会话ID
     * @param engineErrno 引擎内部错误码
     * @return 错误响应对象
     */
    public static ErrorResponse createEngineError(int code, String sid, int engineErrno) {
        ErrorResponse response = new ErrorResponse();
        response.code = code;
        response.message = "WrapperInitErr;errno=" + engineErrno;
        response.suggestion = ErrorCode.getSuggestion(code);
        response.sid = sid;
        return response;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getSuggestion() {
        return suggestion;
    }

    public void setSuggestion(String suggestion) {
        this.suggestion = suggestion;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }
} 